/*
 * 销售合同请求
 * 240716
 *
 */

import { http } from "@/utils/http";
import { baseUrlApi } from "@/store/utils";

// 获取销售合同列表
export const getSalesContractsList = (params?: object) => {
  return http.request("get", baseUrlApi("saleContract/list"), { params });
};

// 获取内部/外部项目列表
export const getProjectList = (params?: object) => {
  return http.request("get", baseUrlApi("project/list"), { params });
};

// 获取内部/外部组织列表
export const getOrgList = (params?: object) => {
  return http.request("get", baseUrlApi("dept/tree"), { params });
};
// 部门新增
export const deptAdd = (data?: object) => {
  return http.request("post", baseUrlApi("dept/add"), { data });
};
// 部门修改
export const deptUpdate = (data?: object) => {
  return http.request("post", baseUrlApi("dept/update"), { data });
};
// 部门修改
export const deptDelete = (data?: object) => {
  return http.request("post", baseUrlApi("dept/delete"), { data });
};

// 获取内部/外部组织人员列表
export const getOrgMenberList = (params?: object) => {
  return http.request("get", baseUrlApi("user/dept/list"), { params });
};

// 获取供应商列表
export const getSupplierList = (params?: object) => {
  return http.request("get", baseUrlApi("supplier/list"), { params });
};

// 获取合同编号
export const getContractNo = (params?: object) => {
  return http.request("get", baseUrlApi("saleContract/generate/code"), {
    params
  });
};

// 保存销售合同，第一步
export const saveSalesContractStepOne = (data?: object) => {
  return http.request("post", baseUrlApi("saleContract/save"), { data });
};

// 保存项目收货人
export const saveProjectReceiver = (data?: object) => {
  return http.request("post", baseUrlApi("contract/contacter/save"), {
    data
  });
};

// 获取销售合同详情
export const getSalesContractDetail = (params?: object) => {
  return http.request("get", baseUrlApi("saleContract/info"), {
    params
  });
};

// 获取项目收货人
export const getProjectReceiver = (params?: object) => {
  return http.request("get", baseUrlApi("contract/contacter/list"), {
    params
  });
};

// 删除销售合同
export const delSalesContract = (data?: object) => {
  return http.request("post", baseUrlApi("saleContract/deleted"), {
    data
  });
};

// 提交审批
export const submitAudit = (data?: object) => {
  return http.request("post", baseUrlApi("saleContract/submit/approval"), {
    data
  });
};

// 撤回
export const revokeAudit = (data?: object) => {
  return http.request("post", baseUrlApi("saleContract/revocation"), {
    data
  });
};

// 获取付款节点表单数据
export const getNodePayFormData = (params?: object) => {
  return http.request("get", baseUrlApi("contract/wire/pay/info"), {
    params
  });
};

// 获取付款节点表格数据
export const getNodePayTableData = (params?: object) => {
  return http.request("get", baseUrlApi("contract/node/pay/list"), {
    params
  });
};

// 保存付款节点数据 - 第二页
export const saveNodePayData = (data?: object) => {
  return http.request("post", baseUrlApi("contract/wire/pay/save"), {
    data
  });
};

// 获取材料表格数据
export const getMaterialList = (params?: object) => {
  return http.request("get", baseUrlApi("material/list"), {
    params
  });
};

// 导入合同材料
export const importMaterialList = (formData: FormData) => {
  return http.request("post", baseUrlApi("contract/import/material/file"), {
    data: formData,
    headers: {
      "Content-Type": "multipart/form-data" // 设置正确的请求头
    }
  });
};

// 获取合同材料表格数据
export const getContractMaterialList = (params?: object) => {
  return http.request("get", baseUrlApi("contract/material/list"), {
    params
  });
};

// 获取合同材料表尾数据
export const getContractMaterialFooter = (params?: object) => {
  return http.request("get", baseUrlApi("contract/material/count"), {
    params
  });
};

// 单条/多条删除合同材料数据
export const deleteContractMaterial = (data?: object) => {
  return http.request("post", baseUrlApi("contract/material/deleted"), {
    data
  });
};

// 保存第三步的数据
export const saveContractMeterialData = (data?: object) => {
  return http.request("post", baseUrlApi("contract/material/save"), {
    data
  });
};

// 删除项目收货人
export const deleteReceiverContacts = (data?: object) => {
  return http.request("post", baseUrlApi("contract/contacter/deleted"), {
    data
  });
};

// 删除付款方式节点
export const deletePayNode = (data?: object) => {
  return http.request("post", baseUrlApi("contract/node/pay/deleted"), {
    data
  });
};

// 获取销售合同对应的采购合同ID
export const getSalesProcureId = (params?: object) => {
  return http.request("get", baseUrlApi("saleContract/purchase/info"), {
    params
  });
};

// 处理审批
export const saleContractApproval = (data?: object) => {
  return http.request("post", baseUrlApi("saleContract/approval"), { data });
};
